import {createSlice} from '@reduxjs/toolkit'
interface IAppState{
    collapsed:boolean
}

// const initialState = {
//     collapsed:false
// } as IAppState
const initialState = {
    collapsed:localStorage.getItem('collapsed') === 'true'
} as IAppState

export const appSlice = createSlice({
    name:'app',
    initialState,
    reducers:{
        changeCollapsed(state){
            // 每次操作的时候存储到本地
            localStorage.setItem('collapsed',String(!state.collapsed))
            state.collapsed = !state.collapsed
        }
    }
})

export const {changeCollapsed} = appSlice.actions
export default appSlice.reducer

